class BaseComponent extends eui.Component{
	public index:number;
	public constructor(index:number) {
		super();
		this.index=index;
	}
	protected childrenCreated(){
		super.childrenCreated();
		/**初始化 */
		this.onChildrenCreated();
		/**添加监听 */
		this.addListener();
	}
	/**初始操作 */
	public onChildrenCreated(){
		
	}
	/**添加监听 */
	public addListener(){
		this.addEventListener(egret.Event.ADDED_TO_STAGE,this.addToStage,this);
		this.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.removeFromStage,this);
		App.EventManager.addEventListener(GameConstants.UI_WILL_APPEAR,this._viewWillAppear,this);
		App.EventManager.addEventListener(GameConstants.UI_WILL_DISAPPEAR,this._viewWillDisAppear,this);
	}
	/**移除监听 */
	public removeListener(){
		this.removeEventListener(egret.Event.ADDED_TO_STAGE,this.addToStage,this);
		this.removeEventListener(egret.Event.REMOVED_FROM_STAGE,this.removeFromStage,this);
		App.EventManager.removeEventListener(GameConstants.UI_WILL_APPEAR,this._viewWillAppear,this);
		App.EventManager.removeEventListener(GameConstants.UI_WILL_DISAPPEAR,this._viewWillDisAppear,this);
	}
	/**添加到舞台 */
	public addToStage(){
	}
	/**移除出舞台 */
	public removeFromStage(){
		this.removeListener();
	}
	public addToParent(parent:eui.UILayer=null){

	}
	public removeFromParent(parent:eui.UILayer=null){

	}
	private _viewWillAppear(index:number){
		if(index == this.index){
			this.viewWillAppear();
		}
	}
	public viewWillAppear():void{
		
	}
	private _viewWillDisAppear(index:number):void{
		if(index == this.index){
			this.viewWillDisAppear();
		}
	}
	public viewWillDisAppear():void{
		
	}
}